*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*	This is the Denver Master program for VAM2 analysis
*	----------------------------------------------------------------------------

	clear all
	set more off
	set maxvar 	120000
	set matsize 11000
	set emptycells drop
	graph set window fontface "CMU Serif"
	set scheme modern

*	city

	global city			DEN

*	paths

	global rawdata 				"${data_raw_DEN}"
	global cleandata 			"${data_clean_DEN}"
	global builddata 			"${data_build_DEN}"

*	sample

	if "$city" == "DEN"{
		local fg	 		6		// first grade
		local lg	 		6		// last grade
		local fy  			2012	// first year
		local ly	   		2018	// last year

		local testgrade				// only for 9th grade only, can specify 9 (PSAT 8/9), 10 (PSAT 10) or 11 (SAT).

		//for labelling output
		global stag `=substr("`fy'",3,2)'`=substr("`ly'",3,2)'G`fg'`lg'

		global sectors cmo non_cmo innovation

		local min_enroll	1
		local min_at_risk	1
	}

	local sample "_`fg'_`lg'_`fy'_`ly'"
	local sch_res "_e`min_enroll'_q`min_at_risk'"

*	controls

	global bl_demos bl_female bl_black bl_white bl_hispanic bl_asian bl_fr_lunch bl_sped bl_ell
	global bl_scores bl_math bl_ela bl_math2 bl_ela2 bl_math3 bl_ela3

	global iv_controls "i.year##(i.grade c.($bl_demos) c.($bl_scores))"

*	settings

	local ptype					form
	local bw

	*	switches

		local descriptives			1	// Table 1
		local testing				1	// Table 2, 3, A3, A4
		local balance				1	// Table A1
		local attrition				1	// Table A2
		local viv					1	// Figure 1, A1
		local testing_het			1	// Table A5

	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	*	do

		if `descriptives'				do "${code_analysis}a_descriptives"			`sample' `sch_res' `ptype' `bw'

		if `testing' {
										local het 0
										do "${code_analysis}a_testing"				`sample' `sch_res' `ptype' `het' `bw'
		}

		if `balance'					do "${code_analysis}a_balance"				`sample' `sch_res' `ptype' `bw'

		if `attrition'					do "${code_analysis}a_attrition"			`fg' `lg' `fy' `ly' `sch_res' `ptype' `bw'

		if `viv'						do "${code_analysis}a_viv"					`sample' `sch_res' `ptype' `bw'

		if `testing_het' {
										local het 1
										do "${code_analysis}a_testing"				`sample' `sch_res' `ptype' `het' `bw'
		}
